package com.wc.算法提高课.A第一章_动态规划.状态压缩DP.愤怒的小鸟;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/11 16:35
 * @description https://www.acwing.com/problem/content/526/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 18, M = 1 << N;
    static double eps = 1e-8;
    // f[i] 表示状态为i的最小射击次数
    static int[] f = new int[M];
    static double[][] q = new double[N][2];
    // 表示射击第path[i][j] 表示射击第i只以及第j只所需要的线所能射击的状态
    static int[][] path = new int[N][N];
    static int T, n, m;

    static boolean eq(double x, double y) {
        return Math.abs(x - y) <= eps;
    }

    public static void main(String[] args) {
        T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            m = sc.nextInt();
            for (int i = 0; i < n; i++) {
                q[i][0] = sc.nextDouble();
                q[i][1] = sc.nextDouble();
            }
            for (int i = 0; i < n; i++) Arrays.fill(path[i], 0, n, 0);
            for (int i = 0; i < n; i++) {
                // 防止只有一个点
                path[i][i] = 1 << i;
                for (int j = 0; j < n; j++) {
                    double x1 = q[i][0], y1 = q[i][1];
                    double x2 = q[j][0], y2 = q[j][1];
                    // 因为这里面有的是没有更新的
                    if (eq(x1, x2)) continue;
                    double a = (y1 / x1 - y2 / x2) / (x1 - x2), b = y1 / x1 - a * x1;
                    // 再如这个没有更新的
                    if (a >= 0) continue;
                    // 检查这个线所能穿过的点
                    int state = 0;
                    for (int k = 0; k < n; k++) {
                        double x = q[k][0], y = q[k][1];
                        if (eq(a * x * x + b * x, y)) state += 1 << k;
                    }
                    path[i][j] = state;
                }
            }
            // 最多是n + 1种
            for (int i = 0; i < 1 << n; i++) f[i] = n + 1;
            f[0] = 0;
            // 遍历所有状态, 最后一个状态是不需要射击的
            for (int i = 0; i + 1 < 1 << n; i++) {
                int x = 0;
                // 找到这个里面没有被击中的猪
                for (int j = 0; j < n; j++) {
                    if ((i >> j & 1) == 0) {
                        x = j;
                        break;
                    }
                }
                // 找到可以击中该猪的抛物线
                for (int j = 0; j < n; j++) {
                    f[i | path[x][j]] = Math.min(f[i | path[x][j]], f[i] + 1);
                }
            }
            out.println(f[(1 << n) - 1]);
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
